package MyFunction2;

public class MyPolynomial implements Polynomial {
	private double[] cofficients;
	private int degree;

	public MyPolynomial(int newDegree, double cofficient) {
		cofficients = new double[newDegree + 1];
		cofficients[newDegree] = cofficient;
		degree = newDegree;
	}

	public MyPolynomial(int newDegree, double[] cofficient) {
		cofficients = cofficient;
		degree = newDegree;
	}

	@Override
	public MyPolynomial addition(MyPolynomial p) {
		MyPolynomial newPolynomial = new MyPolynomial(Math.max(this.degree,
				p.degree), 0);
		for (int i = 0; i <= p.degree; i++) {
			newPolynomial.cofficients[i] = this.cofficients[i];
		}
		for (int i = 0; i <= p.degree; i++) {
			newPolynomial.cofficients[i] += p.cofficients[i];
		}
		return newPolynomial;
	}

	@Override
	public MyPolynomial subtraction(MyPolynomial p) {
		MyPolynomial newPolynomial = new MyPolynomial(Math.max(this.degree,
				p.degree), 0);
		for (int i = 0; i <= p.degree; i++) {
			newPolynomial.cofficients[i] = this.cofficients[i];
		}
		for (int i = 0; i <= p.degree; i++) {
			newPolynomial.cofficients[i] -= p.cofficients[i];
		}
		return newPolynomial;
	}

	@Override
	public MyPolynomial multiplication(MyPolynomial p) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MyPolynomial differentiation() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public double evaluate(double xValue) {
		// TODO Auto-generated method stub
		return 0;
	}

}
